﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SD.IBUS;
using SD.Entities;
using System.Data;
using SD.IDAL;
using SD.DAL;
using System.Data.SqlClient;

namespace SD.BUS
{
    public class ServiceBIZ:BaseBIZ,IServiceBIZ
    {
        IServiceDAO serviceDAO;

        public ServiceBIZ()
        {
            serviceDAO = new ServiceDAO();
        }

        #region IServiceBIZ Members

        /// <summary>
        /// Get all service by includeInactive
        /// </summary>
        /// <param name="includeInactive"></param>
        /// <returns></returns>
        public DataTable GetAll(Boolean includeInactive)
        {
            DataTable dtResult = new DataTable();
            dtResult.Columns.Add("ServiceId");
            dtResult.Columns.Add("Name");

            List<Service> list = new List<Service>();
            list = serviceDAO.GetAll(includeInactive);
            //If rows of list >0
            if (list.Count > 0)
            {
                //Get service from list service
                foreach (Service ser in list)
                {
                    dtResult.Rows.Add(ser.ServiceId, ser.Name);
                }
            }
            return dtResult;
        }

        public DataTable GetAllInfo(bool includeInactive)
        {
            throw new NotImplementedException();
        }

        public DataTable GetAllInfoByFilter(string filterExpression, bool includeInactive)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Get service by id
        /// </summary>
        /// <param name="serviceId">ID of the service</param>
        /// <returns>Found service</returns>
        public Service GetById(String serviceId)
        {
            try
            {
                return serviceDAO.GetById(serviceId);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }

        public bool Insert(Service service)
        {
            throw new NotImplementedException();
        }

        public bool Update(Service service)
        {
            throw new NotImplementedException();
        }

        public bool SetActive(string serviceId, bool isActive)
        {
            throw new NotImplementedException();
        }

        public bool IsDuplicateName(string checkedName)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
